<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="ulke" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{ulkeHome.managed ? 'Edit' : 'Add'} Ulke</f:facet>


            <s:decorate id="idField" template="layout/edit.xhtml">
                <ui:define name="label">Id</ui:define>
                <h:inputText id="id"
                       required="true"
                          value="#{ulkeHome.instance.id}"
                           size="26">
                    <a:support event="onblur" reRender="idField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <s:decorate id="iptalField" template="layout/edit.xhtml">
                <ui:define name="label">Iptal</ui:define>
                <h:inputText id="iptal"
                          value="#{ulkeHome.instance.iptal}">
                    <a:support event="onblur" reRender="iptalField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="ulkeAdiField" template="layout/edit.xhtml">
                <ui:define name="label">Ulke adi</ui:define>
                <h:inputText id="ulkeAdi"
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{ulkeHome.instance.ulkeAdi}">
                    <a:support event="onblur" reRender="ulkeAdiField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="ulkeKoduField" template="layout/edit.xhtml">
                <ui:define name="label">Ulke kodu</ui:define>
                <h:inputText id="ulkeKodu"
                       required="true"
                           size="5"
                      maxlength="5"
                          value="#{ulkeHome.instance.ulkeKodu}">
                    <a:support event="onblur" reRender="ulkeKoduField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{ulkeHome.persist}"
                       disabled="#{!ulkeHome.wired}"
                       rendered="#{!ulkeHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{ulkeHome.update}"
                       rendered="#{ulkeHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{ulkeHome.remove}"
                      immediate="true"
                       rendered="#{ulkeHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Ulke.xhtml"
                rendered="#{ulkeHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty ulkeFrom ? 'UlkeList' : ulkeFrom}.xhtml"
                rendered="#{!ulkeHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Illers">
        <h:form styleClass="association" id="illersChildren">

            <h:outputText value="There are no illers associated with this ulke."
                       rendered="#{empty ulkeHome.illers}"/>

            <rich:dataTable value="#{ulkeHome.illers}"
                           var="_iller"
                      rendered="#{not empty ulkeHome.illers}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="illersTable">
                <rich:column sortBy="#{_iller.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_iller.id}">
                        <f:convertNumber/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_iller.ilAdi}">
                    <f:facet name="header">Il adi</f:facet>
                    <h:outputText value="#{_iller.ilAdi}"/>
                </rich:column>
                <rich:column sortBy="#{_iller.plakaKodu}">
                    <f:facet name="header">Plaka kodu</f:facet>
                    <h:outputText value="#{_iller.plakaKodu}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{ulkeHome.managed}" id="illers">
        <div class="actionButtons">
            <s:button id="addiller"
                   value="Add iller"
                    view="/IllerEdit.xhtml"
             propagation="none">
                 <f:param name="ulkeId"
                         value="#{ulkeHome.instance.id}"/>
                 <f:param name="illerFrom" value="Ulke"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
